package br.unipar.bancodedados;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class App {

    public App() {
        try {
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost:3306/unipar";
            String user = "root";
            String senha = "teste";

            Class.forName(driver);
            Connection conn = DriverManager.getConnection(url, user, senha);
            Statement stmt = conn.createStatement();

            String sql = "select id, login, senha from Usuario";
            ResultSet result = stmt.executeQuery(sql);

            while (result.next()) {
                System.out.println("ID : " + result.getLong("id"));
                System.out.println("Login : " + result.getString("login"));
                System.out.println("Senha : " + result.getString("senha"));
            }

            stmt.close();
            conn.close();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new App();
    }
}
